/* Copyright (c) 2004-2024 peigen.info. All rights reserved. */

package info.peigen.hotpot.business.account.manage.controller;

import info.peigen.hotpot.business.account.manage.form.AccountManageCreateForm;
import info.peigen.hotpot.business.account.manage.form.AccountManageEditForm;
import info.peigen.hotpot.business.account.manage.form.AccountManageSearchForm;
import info.peigen.hotpot.business.account.manage.info.AccountManageInfo;
import info.peigen.hotpot.business.account.manage.service.AccountManageService;
import info.peigen.hotpot.common.core.result.PageResult;
import info.peigen.hotpot.common.core.result.manage.WebResult;
import info.peigen.hotpot.component.data.repository.beetlsql.filter.ManageDataAspect;
import org.noear.solon.annotation.Body;
import org.noear.solon.annotation.Controller;
import org.noear.solon.annotation.Inject;
import org.noear.solon.annotation.Mapping;
import org.noear.solon.validation.annotation.Valid;

/**
 * <b>(AccountManageController)</b>
 * 管理后台 "账户"控制器
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2023-08-29
 */
@SuppressWarnings({"rawtypes", "unchecked", "unused"})
@Valid
@Controller
@Mapping("account")
public class AccountManageController {
    @Inject
    AccountManageService accountManageService;

    @Mapping("page")
    @ManageDataAspect
    WebResult page(@Body AccountManageSearchForm form) {
        PageResult<AccountManageInfo> page = accountManageService.page(form);
        return WebResult.setSuccessResult().setInfo(page);
    }

    @Mapping("create")
    @ManageDataAspect
    WebResult create(@Body AccountManageCreateForm form) {
        accountManageService.create(form);
        return WebResult.setSuccessResult();
    }

    @Mapping("edit")
    @ManageDataAspect
    WebResult edit(@Body AccountManageEditForm form) {
        accountManageService.edit(form);
        return WebResult.setSuccessResult();
    }

    @Mapping("remove")
    @ManageDataAspect
    WebResult remove(@Body AccountManageSearchForm form) {
        accountManageService.remove(form.getId());
        return WebResult.setSuccessResult();
    }
}
